package model.commands.flow;

import model.commands.AbstractCompositeCommand;


public class Repeat extends AbstractCompositeCommand {
	private Integer times = null;

	@Override
	public void execute() {
		resetRunningVariables();
		if(times == null || times < 0){
			while(!stop){
				executeInnerCommands();
			}
		}else{
			for(int i = 0; i< times.intValue(); i++ ){
				executeInnerCommands();
			}
		}
		propertyChangeSupport.firePropertyChange(EXECUTION_FINISHED, null, this);

	}

	@Override
	public void setParams(Object[] params) {
		times = (Integer)params[0];
	}

	public Integer getTimes() {
		return times;
	}
	
}
